<div class="box-body">
    <form class="layui-form" action="{:url('/cha/channel/update')}" method="post" style="width:550px; max-height: 90%;">
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">承运商	</label>
            <div class="layui-input-block">
                <select name="carrier_id">
                    <option value="">请选择</option>
                    {foreach $carrier as $c}
                    <option {if isset($channel) && $c.carrier_id==$channel.carrier_id}selected{/if} value="{$c.carrier_id}">{$c.carrier_name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">渠道名称</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="渠道名称"  name="channel_name" {if isset($channel)}value="{$channel.channel_name}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">渠道编号</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="渠道编号"  name="channel_num" {if isset($channel)}value="{$channel.channel_num}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">渠道类型</label>
            <div class="layui-input-block">
                <select name="channel_type">
                    <option value="">请选择</option>
                    {foreach $channel_type as $k=>$c}
                    <option {if isset($channel) && $c==$channel.channel_type}selected{/if} value="{$k}">{$c}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否可追踪</label>
            <div class="layui-input-block">
                <select name="is_track">
                    {foreach $is_track as $k=>$c}
                    <option {if isset($channel) && $c==$channel.is_track}selected{/if} value="{$k}">{$c}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">追踪号获取方式</label>
            <div class="layui-input-block">
                <select name="track_type">
                    {foreach $track_type as $k=>$c}
                    <option {if isset($channel) && $c==$channel.track_type}selected{/if} value="{$k}">{$c}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">面单获取方式</label>
            <div class="layui-input-block">
                <select name="label_type">
                    {foreach $label_type as $k=>$c}
                    <option {if isset($channel) && $c==$channel.label_type}selected{/if} value="{$k}">{$c}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">面单宽(mm)</label>
            <div class="layui-input-block">
                <input type="number" autocomplete="off" placeholder="默认(100mm)"  name="label_width" {if isset($channel)}value="{$channel.label_width}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">面单高(mm)</label>
            <div class="layui-input-block">
                <input type="number" autocomplete="off" placeholder="默认(100mm)"  name="label_height" {if isset($channel)}value="{$channel.label_height}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">起重(g)</label>
            <div class="layui-input-block">
                <input type="number" autocomplete="off" placeholder="起重(g)"  name="default_weight" {if isset($channel)}value="{$channel.default_weight}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">折扣(%)</label>
            <div class="layui-input-block">
                <input type="number" autocomplete="off" placeholder="折扣"  name="default_discount" {if isset($channel)}value="{$channel.default_discount|default=100}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">回邮地址</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="回邮地址"  name="return_address" {if isset($channel)}value="{$channel.return_address}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">特许码</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="特许码"  name="special_code" {if isset($channel)}value="{$channel.special_code}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分练码</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="分练码"  name="part_code" {if isset($channel)}value="{$channel.part_code}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单日最大发货量</label>
            <div class="layui-input-block">
                <input type="number" autocomplete="off" placeholder="单日最大发货量,如果为0不限制"  name="day_max_shipping" {if isset($channel)}value="{$channel.day_max_shipping|default=0}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="checkbox" name="status" value="1" {if !isset($channel) || (isset($channel) && $channel.status)}checked{/if} lay-skin="switch">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">对接类</label>
            <div class="layui-input-block">
                <select name="classes">
                    <option value="">请选择</option>
                    {foreach $service as $s}
                    <option {if isset($channel) && $s==$channel.classes}selected{/if} value="{$s}">{$s}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        {if isset($channel) && !empty($channel.classes)}
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">api请求根路径</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="例如：http://wwww.lmterp.cn"  name="api_base_url" {if isset($channel)}value="{$channel.api_base_url}"{/if} class="layui-input" />
            </div>
        </div>
        {/if}
        <div class="layui-form-item">
            <label class="layui-form-label">对接文档链接</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="对接文件链接"  name="document_path" {if isset($channel)}value="{$channel.document_path}"{/if} class="layui-input" />
            </div>
        </div>
        {if isset($tokenField)}
        {foreach $tokenField['required'] as $r}
        {php}$field=$r['field'];{/php}
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">{$r.name}</label>
            <div class="layui-input-block">
                {if $r.type == 'select'}
                <select name="token_{$r.field}">
                    <option value="">请选择</option>
                    {foreach $r['value'] as $k=>$v}
                    <option {if isset($channel->token->$field) && $channel->token->$field == $k}selected{/if} value="{$k}">{$v}</option>
                    {/foreach}
                </select>
                {else}
                <input type="text" {if isset($r['readonly']) && $r['readonly']}readonly style="border: 0px;"{/if} name="token_{$r.field}" {if isset($channel->token->$field)}value="{$channel->token->$field}"{/if} placeholder="密钥可为空，若填一项带星号的都必填" class="layui-input">
                {/if}
            </div>
        </div>
        {/foreach}
        {foreach $tokenField['option'] as $r}
        {php}$field=$r['field'];{/php}
        <div class="layui-form-item">
            <label class="layui-form-label">{$r.name}</label>
            <div class="layui-input-block">
                {if $r.type == 'select'}
                <select name="token_{$r.field}">
                    <option value="">请选择</option>
                    {foreach $r['value'] as $k=>$v}
                    <option {if isset($channel->token->$field) && $channel->token->$field == $k}selected{/if} value="{$k}">{$v}</option>
                    {/foreach}
                </select>
                {else}
                <input type="text" {if isset($r['readonly']) && $r['readonly']}readonly style="border: 0px;"{/if} name="token_{$r.field}" {if isset($channel->token->$field)}value="{$channel->token->$field}"{/if} placeholder="可不填" class="layui-input">
                {/if}
            </div>
        </div>
        {/foreach}
        {/if}
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="number" autocomplete="off" placeholder="排序"  name="sort" {if isset($channel)}value="{$channel.sort}"{/if} class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" placeholder="备注"  name="remark" {if isset($channel)}value="{$channel.remark}"{/if} class="layui-input" />
            </div>
        </div>
        {if isset($channel)}
        <input type="hidden" name="channel_id" value="{$channel.channel_id}">
        {/if}
    </form>
</div>